﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MindFusion.Diagramming;

namespace WindowsFormsApplication1
{
    public partial class FormChangeName : Form
    {
        Form1 f;

        public FormChangeName()
        {
            InitializeComponent();
        }

        private void FormChangeName_Activated(object sender, EventArgs e)
        {
            this.Opacity = 1;
            txtName.SelectAll();
        }

        private void FormChangeName_Deactivate(object sender, EventArgs e)
        {
            this.Opacity = 0.5;
            txtName.DeselectAll();
        }

        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (f.diagram.Selection.Nodes.Count > 0)
            {
                (f.diagram.Selection.Nodes[0] as ShapeNode).Text = txtName.Text;
                f.diagramView.Refresh();
            }
            this.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            if (f.diagram.Selection.Nodes.Count > 0)
                txtName.Text = (f.diagram.Selection.Nodes[0] as ShapeNode).Text;
            this.Close();
        }

        private void FormChangeName_Load(object sender, EventArgs e)
        {
            f = (Owner as Form1);
            txtName.SelectAll();
        }
    }
}
